package com.example.springaop.aop.service;

import com.alibaba.fastjson.JSONObject;
import com.dingtalk.open.app.api.OpenDingTalkStreamClientBuilder;
import com.dingtalk.open.app.api.security.AuthClientCredential;

/**
 * @author: 任福祥
 * * @create: 2024-01-26 17:44
 */
public class Test {

    private static final String clientId = "dinggwxiesku6toq9rsh";
    private static final String clientSecret = "xx8K2OkZXN-ef_0eLMtgQHQHJp1MQy55Uzelojr8yYcy2kOXScHxmeM4Q5ZdxIn1";
    private static final String topic = "/v1.0/im/bot/messages/get";

    public static void main(String[] args) throws Exception {
        OpenDingTalkStreamClientBuilder
                .custom()
                .credential(new AuthClientCredential(clientId, clientSecret))
                //注册机器人监听器
                .registerCallbackListener(topic, robotMessage -> {
//                    log.info("receive robotMessage, {}", robotMessage);
                    System.out.println(JSONObject.toJSONString(robotMessage));
                    //开发者根据自身业务需求，处理机器人回调
                    return "new JSONObject()";

                })
                .build().start();
    }
}